package pos.domain;

import java.util.List;

import pos.data.JDBCDisciplineDAO;

public class DisciplineStore {

	@SuppressWarnings("unused")
	private List<Discipline> disciplines;
	private static DisciplineStore disciplineStore;
	
	public static synchronized DisciplineStore getInstance() {
		disciplineStore = new DisciplineStore();
		
		return disciplineStore;
	}
	public DisciplineStore() {
		disciplines = (new JDBCDisciplineDAO()).getAllDisciplines();
	}
	
	public List<Discipline> getDisciplines(){
		return (new JDBCDisciplineDAO()).getAllDisciplines();
	}
	
	public Discipline getDisciplineById(String idDiscipline){
		return (new JDBCDisciplineDAO()).getDisciplineById(idDiscipline);
	}
	
	public Discipline getDisciplineByName(String name){
		return (new JDBCDisciplineDAO()).getDisciplineByName(name);
	}
	
	public Discipline getDisciplineByEvent(Event event){
		return new JDBCDisciplineDAO().getDisciplineByEvent(event.getId());
	}
	
	public Discipline insertDiscipline(Discipline discipline, Category category){
		Discipline dRes = null;
		dRes = new JDBCDisciplineDAO().insertDiscipline(discipline, category.getId());

		return dRes;
	}
	
	public void removeDiscipline(Discipline discipline){
		// didn't remove the associations because the objective is to have data
		new JDBCDisciplineDAO().removeDiscipline(discipline); 
	}
	
	public boolean existDiscipline(Discipline discipline){
		return new JDBCDisciplineDAO().existDiscipline(discipline.getName());
	}
}
